<template>
  <div class="comingSoon">
    <div class="title">
      {{ data.name }}
    </div>

    <div class="top-other">
      <el-carousel
        :interval="5000"
        arrow="always"
        height="24.31rem"
        indicator-position="none"
      >
        <el-carousel-item
          v-for="items in count"
          :key="items"
        >
          <div
            v-for="(item, str) in list"
            :key="str"
            class="goods-item"
            @click="goDetail(item)"
          >
            <div v-if="str >= (items - 1) * 2 && str < items * 2">
              <img
                :src="item.defaultAlbum"
                alt=""
                class="goods-img"
              >
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="more">
      <img
        src="../../assets/img/logo2.png"
        alt=""
        @click="toList"
      >
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {
    data: {
      type: Object,
      // 对象或数组默认值必须从一个工厂函数获取
      default: function () {
        return {};
      },
    },
  },
  data() {
    return {
      list: [],
      count: "",
    };
  },
  mounted() {
    let params = {
      queryCondition: {
        order: [
          {
            fieldname: "iOrder",
            direction: "asc",
          },
        ],
        pageindex: 1,
        pagesize: 16,
        where: [
          {
            fieldname: "tag_id",
            valuefrom: this.data.connect_id,
          },
        ],
      },
    };

    this.$api.home.getProductList(params).then((res) => {
      if (res.code == 200) {
        this.list = res.data.data;
        this.count = Math.ceil(res.data.data.length / 2);
      }
    });
  },
  methods: {
    toList() {
      this.$router.push({
        path: "/today",
        query: {
          id: this.data.connect_id,
        },
      });
    },
    //跳转商品详情
    goDetail(item) {
      this.$router.push({
        path: "/fruit/detail",
        query: {
          id: item.pid,
          iShopId: item.iShopId
        },
      });
    },
  },
};
</script>

<style scoped lang="scss">
.comingSoon {
  padding: 0 16.19rem;
  margin-top: 2.19rem;
  display: flex;
  flex-direction: column;
  .title {
    width: 11.25rem;
    height: 3.44rem;
    background: rgba(0, 0, 0, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: rgba(234, 234, 234, 1);
  }
  .top-other {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    .el-carousel__item {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      .goods-item {
        // width: 100%;
        height: 100%;
        background: #fff;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-around;
        position: relative;
        margin:0 1rem;
        cursor: pointer;
        &:nth-child(2n) {
          margin-right: 0;
        }
        .goods-img {
          width: 100%;
          height: 100%;
          object-fit: contain;
        }
      }
    }
  }
  .more {
    height: 2.5rem;
    background: rgba(0, 0, 0, 1);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 1.44rem;
    img {
      width: 7.38rem;
      cursor: pointer;
    }
  }
}
</style>

